<template>
  <el-switch v-model="row.credit_redeem" :disabled="disabled" :active-value="1" :inactive-value="0" @change="change" />
</template>

<script>
export default {
  props: {
    row: {
      type: Object,
      default: _ => {
        return {};
      }
    }
  },
  data() {
    return {
      disabled: false
    };
  },
  methods: {
    change: function(value) {
      this.disabled = true;
      this.$http.put(
        '/exam/admin/module/' + this.row.module_id + '/special/' + this.row.id + '/edit/credit_redeem',
        { credit_redeem: value },
        response => {
          this.disabled = false;
        },
        error => {
          this.$message.error(error.msg);
        },
        false
      );
    }
  }
};
</script>

<style></style>
